package com.le.tester.webpage.periodCallback;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Timer;

/**
 * 描述：周期性回调测试
 */
public class PeriodicCallbackTester {
    private PeriodicCallback periodicCallback;

    private PeriodicCallbackTester() {
        periodicCallback = new PeriodicCallback();
        periodicCallback.callbackTimes.add(new Callback<LocalDateTime>() {
            @Override
            public void callback(LocalDateTime localDateTime) {
                showLocalTime(localDateTime);
            }
        });
    }

    private void showLocalTime(LocalDateTime localDateTime) {
        System.out.println("当前时间为：" + localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }

    public static void main(String[] args) {
        new PeriodicCallbackTester().periodicCallback.start();
    }


}
